﻿using System.Windows.Interactivity;

namespace PairingMatrix.View.Behavior
{

    public class ImageButtonMouseClickBehavior : Behavior<ImageButton>
    {
        private double zoomScale;

        protected override void OnAttached()
        {
            zoomScale = 1.2;
            AssociatedObject.MouseLeftButtonDown += (sender, e) =>
                                                    {
                                                        AssociatedObject.CaptureMouse();
                                                        AssociatedObject.Height = AssociatedObject.Height/zoomScale;                                                        
                                                        AssociatedObject.Width = AssociatedObject.Width/zoomScale;             
                                                    };
 
            AssociatedObject.MouseLeftButtonUp += (sender, e) =>
                                                  {
                                                      AssociatedObject.ReleaseMouseCapture();

                                                      AssociatedObject.Height = AssociatedObject.Height * zoomScale;                                                        
                                                      AssociatedObject.Width = AssociatedObject.Width * zoomScale;

                                                      AssociatedObject.Command.Execute(null);
                                                      
                                                  };
 
        }
    }
}
